using System.Data;
using Kwd.Summary.Models;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common.Settings;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Kwd.Summary
{
  public partial class Migrations : DataMigrationImpl
  {
    public int Create()
    {
      //add my record.
      this.SchemaBuilder.CreateTable(typeof(SummaryPartRecord).Name, table => table
        .ContentPartRecord()
        .Column("StrategyName", DbType.String)
        .Column<string>("Text")
        .Column<string>("Format")
        );

      //add my part def.
      this.ContentDefinitionManager.AlterPartDefinition(typeof(SummaryPart).Name, builder =>
        builder
        .Attachable()
        .WithSetting(typeof(SummaryPartSettings).Name + ".DefaultFlavor", BodyPartSettings.FlavorDefaultDefault)
        );

      return 1;
    }
  }
}